// ZoneTable.cpp: implementation of the ZoneTable class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "ZoneTable.h"

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
using namespace PDMS::PDMSDBIF;

BEGIN_REGISTER_MAP( ZoneTable, MultiRecordsDatabaseElement)
REGISTER( _T("ZoneData"), GET_REGISTER( DatabaseElementFactory, Design_VersionOne ) )
END_REGISTER_MAP();

ZoneTable::ZoneTable()
{

}

ZoneTable::~ZoneTable()
{

}

void ZoneTable::SetID( unsigned long lID )
{
	m_pCurRecord->SetID( lID );
}

void ZoneTable::SetParentID( unsigned long lParentID )
{
	m_pCurRecord->SetParentID( lParentID );
}

void ZoneTable::SetDescription( const StdString& strDescription )
{
	m_pCurRecord->SetDescription( strDescription );
}

void ZoneTable::SetPurpose( const StdString& strPurpose )
{
	m_pCurRecord->SetPurpose( strPurpose );
}

void ZoneTable::SetFunction( const StdString& strFunction )
{
	m_pCurRecord->SetFunction( strFunction );
}

void ZoneTable::SetNumber( int iNumber )
{
	m_pCurRecord->SetNumber( iNumber );
}

void ZoneTable::SetArea( int iArea )
{
	m_pCurRecord->SetArea( iArea );
}

void ZoneTable::SetDUnion( int iDUnion )
{
	m_pCurRecord->SetDUnion( iDUnion );
}

void ZoneTable::SetModule( const StdString& strModule )
{
	m_pCurRecord->SetModule( strModule );
}

void ZoneTable::SetRlstored( const StdString& strRlstored )
{
	m_pCurRecord->SetRlstored( strRlstored );
}

void ZoneTable::SetPspec( const StdString& strPspec )
{
	m_pCurRecord->SetPspec( strPspec );
}

void ZoneTable::SetIspec( const StdString& strIspec )
{
	m_pCurRecord->SetIspec( strIspec );
}

void ZoneTable::SetTspec( const StdString& strTspec )
{
	m_pCurRecord->SetTspec( strTspec );
}

unsigned long ZoneTable::GetID()
{
	return m_ResPtr->GetLong( _T("ID") );
}

unsigned long ZoneTable::GetParentID()
{
	return m_ResPtr->GetLong( _T("ParentID") );
}

const StdString ZoneTable::GetDescription()
{
	return m_ResPtr->GetString( _T("Description") );
}

const StdString ZoneTable::GetPurpose()
{
	return m_ResPtr->GetString( _T("Purpose") );
}

const StdString ZoneTable::GetFunction()
{
	return m_ResPtr->GetString( _T("Function") );
}

const StdString ZoneTable::GetModule()
{
	return m_ResPtr->GetString( _T("Module") );
}

int ZoneTable::GetNumber()
{
	return m_ResPtr->GetLong( _T("Number") );
}

int ZoneTable::GetArea()
{
	return m_ResPtr->GetLong( _T("Area") );
}

int ZoneTable::GetDUnion()
{
	return m_ResPtr->GetLong( _T("DUnion") );
}

const StdString ZoneTable::GetRlstored()
{
	return m_ResPtr->GetString( _T("Rlstored") );
}

const StdString ZoneTable::GetPspec()
{
	return m_ResPtr->GetString( _T("Pspec") );
}

const StdString ZoneTable::GetIspec()
{
	return m_ResPtr->GetString( _T("Ispec") );
}

const StdString ZoneTable::GetTspec()
{
	return m_ResPtr->GetString( _T("Tspec") );
}

StdString ZoneTable::GetOpenSQL( const StdString& strCondition )
{
	StdString strTemp( _T("Select * from ZoneData ") );
	if ( strCondition == ALLRECORD )
	{
		return strTemp;
	}
	
	return strTemp + _T("Where ") + strCondition;
}

StdString ZoneTable::GetTableName()
{
	return StdString( _T("ZoneData") );
}

void ZoneTable::SetData( RecordPtr_ ptr )
{
	ASSERT( ptr != NULL );

	m_ResPtr->SetLong( _T( "ID" ), ptr->GetID() );
	m_ResPtr->SetLong( _T( "ParentID" ), ptr->GetParentID() );
	m_ResPtr->SetString( _T( "Description" ), ptr->GetDescription() );
	m_ResPtr->SetString( _T( "Purpose" ), ptr->GetPurpose() );
	m_ResPtr->SetString( _T( "Function" ), ptr->GetFunction() );
	m_ResPtr->SetString( _T( "Module" ), ptr->GetModule() );
	m_ResPtr->SetLong( _T( "Number" ), ptr->GetNumber() );
	m_ResPtr->SetLong( _T( "Area" ), ptr->GetArea() );
	m_ResPtr->SetLong( _T( "DUnion" ), ptr->GetDUnion() );
	m_ResPtr->SetString( _T( "Rlstored" ), ptr->GetRlstored() );
	m_ResPtr->SetString( _T( "Pspec" ), ptr->GetPspec() );
	m_ResPtr->SetString( _T( "Ispec" ), ptr->GetIspec() );
	m_ResPtr->SetString( _T( "Tspec" ), ptr->GetTspec() );
}